home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / HARDWARE.SWG / 0038_Detect a 286-Able machine.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  1KB  |  64 lines

  1. {
  2. >>> Well, I have it now: the program was compiled in G+ mode (enable
  3. >>> 286-instructions) and it therefore bombed on an 8088 or 8086
  4. >>> machine. Too bad it didn't do so graciously with a proper error.
  5.  
  6. I've thrown together this little unit here - if your program or unit uses
  7. $G+, just add this as the FIRST! unit in the USES clause. It is called
  8. _286.PAS:
  9. }
  10.  
  11. (*
  12.   Programs compiled with {$G} compiler directive enabled do not
  13.   check the processor at runtime to determine whether it is
  14.   286-compatible. Trying to execute 80286 instructions on an 8086
  15.   or an 8088 will lock up the computer. This program checks
  16.   for the presence of a 286-compatible chip at runtime.
  17.  
  18.   Put this unit as the FIRST in the USES clause.
  19. *)
  20.  
  21. Unit _286;
  22.  
  23. Interface
  24.  
  25. Implementation
  26.  
  27. function Is286Able : Boolean; assembler;
  28. asm
  29.   PUSHF
  30.   POP     BX
  31.   AND     BX,0FFFH
  32.   PUSH    BX
  33.   POPF
  34.   PUSHF
  35.   POP     BX
  36.   AND     BX,0F000H
  37.   CMP     BX,0F000H
  38.   MOV     AX,0
  39.   JZ      @@1
  40.   MOV     AX,1
  41.  @@1:
  42. end;
  43.  
  44. begin
  45.   if not Is286Able then
  46.   begin
  47.     Writeln('Need an 80286-compatible system to run this program');
  48.     Halt(1);
  49.    end;
  50. end.
  51.  
  52. {--------------------- CUT HERE ------------------}
  53.  
  54. {
  55.  This can be put in individual units, just make sure it is the FIRST
  56.  unit in the USES clause, eg
  57.  
  58.   Uses
  59.     _286,
  60.     Crt,
  61.     Dos,
  62.     KeyTTT5;
  63. }
  64.